﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using VioletDevelopmentLaboratory.Net.Web;

public partial class vboard_webmanager_user_list : VioletDevelopmentLaboratory.Net.Web.PageBase
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			UserGridView_DataBind();
		}
	}

	private void UserGridView_DataBind()
	{
		int totalRecords = 0;

		int pageIndex;

		try
		{
			pageIndex = Convert.ToInt32(Request.QueryString[UserGridViewPagerButton.PageIndexQueryStringName]);
		}
		catch
		{
			pageIndex = 0;
		}

		UserGridView.DataSource = Membership.GetAllUsers(pageIndex, UserGridView.PageSize, out totalRecords);
		UserGridView.DataBind();

		UserGridViewPagerButton.PageSize = UserGridView.PageSize;
		UserGridViewPagerButton.SelectCount = totalRecords;

		NumberOfAllUsersLiteral.Text = totalRecords + "";
		NumberOfUsersOnlineLiteral.Text = Membership.GetNumberOfUsersOnline() + "";
	}
	protected void UserGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
	{
		string username = UserGridView.DataKeys[e.RowIndex].Value.ToString();

		if (!Membership.DeleteUser(username, true))
		{
			VUtility.ShowMessagePanel(Page, "사용자 정보 제거중 오류가 발생했습니다.", true);
			return;
		}

		UserGridView_DataBind();

		VUtility.ShowMessagePanel(Page, "사용자 정보가 제거되었습니다.", true);
	}
	protected void UserGridViewPagerButton_PageIndexChanged(object sender, VioletDevelopmentLaboratory.Net.Web.WebControls.PagerButtonPageIndexChangedEventArgs e)
	{
		Response.Redirect(e.NewPageUrl, true);
	}
}
